package com.sqly.doc.menu.yyye;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.support.annotation.IdRes;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ihidea.multilinechooselib.MultiLineChooseLayout;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.sqly.doc.R;
import com.sqly.doc.base.MyBaseActivity;
import com.sqly.doc.menu.camera.CameraChoose;
import com.sqly.doc.menu.tnb.tnb;
import com.sqly.doc.menu.ycf.ycf_1;
import com.sqly.doc.pojo.JuMin;
import com.sqly.doc.pojo.RetMsg;
import com.sqly.doc.pojo.XseJtfs;
import com.sqly.doc.user.choose_user;
import com.sqly.doc.util.CreateBitmap;
import com.sqly.doc.util.DateConvert;
import com.sqly.doc.util.HttpUrl;
import com.sqly.doc.util.MyToastUtil;
import com.sqly.doc.util.NetWorkUtils;
import com.sqly.doc.util.SharedPreferencesUtils;
import com.sqly.doc.util.SweetAlertDialogUtil;
import com.sqly.doc.util.Url;
import com.sqly.doc.util.UserClient;
import com.sqly.doc.util.WriteActivity;
import com.sqly.doc.view.CustomDatePicker;
import com.sqly.doc.view.StringUtils;

import java.io.File;
import java.io.FileNotFoundException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

//import cn.pedant.SweetAlert.SweetAlertDialog;
import com.cazaea.sweetalert.SweetAlertDialog;

import cz.msebera.android.httpclient.Header;

/**
 */

public class yyye_xser extends MyBaseActivity {

    XseJtfs obj;
    private CustomDatePicker customDatePicker;
    Context con = yyye_xser.this;
    //标题
    TextView title, uname;
    //转诊
    EditText zzyy, jgjkb, lxr, lxdh;
    RadioGroup zzjg;
    String zzjgs = "";
    TextView xcsfrq, csrq, bcsfrq;
    /////////////////////////////////////////////////////内容
    EditText sfzh, jtzz, fqxm, fqzy, fqlxdh, fqsfzj, mq, mqzzy, mqlxdh, mqsfzh, csyz, zcjgmc, cszkqt, xsejbscqt, dbqt;
    MultiLineChooseLayout cszk, xsejbsc, hybw;
    private List<String> cszkdata = new ArrayList<>();
    private List<String> xsejbscdata = new ArrayList<>();
    private List<String> hybwdata = new ArrayList<>();
    MultiLineChooseLayout bjzd;
    private List<String> bjzddata = new ArrayList<>();
    //////////////////////////////////////////////////////////////////内容2
    RadioGroup mqrx, xsezx, jx, xsetlsc, wyfs, outu, dabian, mshr, qx, zz;
    RadioGroup yj, szhdd, wg, jbbk, bi, pf, kq, gm, xftz, xb, xingbie, fbcz, jz, wszq, qd;
    EditText mqrxqt, xsecstz, mqtz, cssc, cnl, cncs, dbcs, tw, xl, hxpl, msqt, qx1, qx2, qxqt, qdqt, zdqt;
    String JKDAH = "";
    boolean isadd = false;//是否是新添加
    String url = "";
    ImageView sfysqm, brqm, xcqm;
    String sfysqmpic = "", brqmpic = "",xcqmpic ="";
    JuMin j;
    TextView xm;

    ImageView xcpaizhao;
    TextView pz_record_id,jmqm_record_id, ysqm_record_id;
    boolean pzChange = false;
    LinearLayout back;

    @Override
    protected void initUI() {
        setContentView(R.layout.et_xser);
        if (NetWorkUtils.isNetworkConnected(con)) {
            if (getIntent().getStringExtra("type").equals("edit")) {
                obj = (XseJtfs) getIntent().getExtras().getSerializable("b");
                init();
                if(!StringUtils.isEmpty(obj.getImg())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg(),brqm);
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg()),brqm);
                }
                if(!StringUtils.isEmpty(obj.getImg1())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg1(),sfysqm);
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg1()),sfysqm);
                }
                if(!StringUtils.isEmpty(obj.getImg2())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg2(),xcqm);
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg2()),xcqm);
                }
                xm.setClickable(false);
            }
            else {
                obj = new XseJtfs();
                init();
            }
        }

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data == null) {
        } else {
            if (requestCode == 1) {
                j = (JuMin) data.getExtras().getSerializable("j");
                getObject();
            }else if (requestCode == 8) {
                String record_id = (String) data.getExtras().getString("record_id");
                ysqm_record_id.setText(record_id);
                byte[] bis = data.getByteArrayExtra("bitmap");
                Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
                Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
                sfysqm.setImageBitmap(bb);
                sfysqmpic = CreateBitmap.saveMyBitmap(bb);
            }else if (requestCode == 9) {
                String record_id = (String) data.getExtras().getString("record_id");
                jmqm_record_id.setText(record_id);
                byte[] bis = data.getByteArrayExtra("bitmap");
                Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
                Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
                brqm.setImageBitmap(bb);
                brqmpic = CreateBitmap.saveMyBitmap(bb);
            }else if(requestCode == 119){
                String img_record_id = (String) data.getExtras().getString("img_record_id");
                pz_record_id.setText(img_record_id);
                pzChange = true;
                byte[] bis = data.getByteArrayExtra("bitmap");
                Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
                Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
                xcqm.setImageBitmap(bb);
            }
        }
    }

    public void init() {
        //医生签名
        sfysqm = (ImageView) findViewById(R.id.sfysqm);
        if (obj != null && !StringUtils.isEmpty(obj.getSfysqm())) {
            sfysqmpic = obj.getSfysqm();
            sfysqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + sfysqmpic + ".jpg"));
        }
        sfysqm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(con, WriteActivity.class)
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "xsejtfs")
                        .putExtra("imageType", "img1")
                        .putExtra("class","yyye_xser.class"), 8);
            }
        });
        //本人签名
        brqm = (ImageView) findViewById(R.id.brqm);
        if (obj != null && !StringUtils.isEmpty(obj.getBrqm())) {
            brqmpic = obj.getBrqm();
            brqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + brqmpic + ".jpg"));
        }
        brqm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(con, WriteActivity.class)
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "xsejtfs")
                        .putExtra("imageType", "img")
                        .putExtra("class","yyye_xser.class"), 9);
            }
        });
        xcqm = (ImageView) findViewById(R.id.xcqm);
        if (obj != null && !StringUtils.isEmpty(obj.getXcqm())) {
            xcqmpic = obj.getXcqm();
            xcqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + xcqmpic + ".jpg"));
        }
        xcqm.setOnClickListener(new CustomerListener());
        //现场拍照
        xcpaizhao = (ImageView) findViewById(R.id.xcpaizhao);
        xcpaizhao.setOnClickListener(new CustomerListener());
        //现场拍照照片id
        pz_record_id = (TextView) findViewById(R.id.pz_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg2())) {
            //fjhdycrhsf/D24E75C5BB5E417EBE65494CA09BF399.jpg
            String[] img2Arr =obj.getImg2().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                pz_record_id.setText(img2Arr[1]);
            }
        }
        jmqm_record_id= (TextView) findViewById(R.id.jmqm_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg())) {
            String[] img2Arr =obj.getImg().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                jmqm_record_id.setText(img2Arr[1]);
            }
        }
        ysqm_record_id= (TextView) findViewById(R.id.ysqm_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg1())) {
            //fjhdycrhsf/D24E75C5BB5E417EBE65494CA09BF399.jpg
            String[] img2Arr =obj.getImg1().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                ysqm_record_id.setText(img2Arr[1]);
            }
        }

        //姓名
        xm = (TextView) findViewById(R.id.XINGMING);
        if (obj != null && !StringUtils.isEmpty(obj.getXINGMING())) {
            xm.setText(obj.getXINGMING());
        } else {
            xm.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    startActivityForResult(new Intent(con, choose_user.class).putExtra("cname", "yyye_xser.class"), 1);
                }
            });
        }
        //标题
        title = (TextView) findViewById(R.id.title);
        uname = (TextView) findViewById(R.id.uname);
        title.setText("新生儿家庭访视记录");
        back = (LinearLayout)findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(pzChange){
                   SweetAlertDialogUtil.WarningDialogHaveCancelAndConfirm(con,"你确认不保存数据更新吗？","现场拍照已经采集，请注意点击“保存”","确定", "返回");
                }else {
                    finish();
                }
            }
        });
        uname.setText("保存");
        uname.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(null == xm.getText().toString() || "".equals(xm.getText().toString())){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "姓名不能为空");
                }else if(null == bcsfrq.getText().toString() || "".equals(bcsfrq.getText().toString())){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "本次随访日期不能为空");
                } else if(null == xcsfrq.getText().toString() || "".equals(xcsfrq.getText().toString())){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "下次随访日期不能为空");
                } else if ("1".equals(SharedPreferencesUtils.getParam(con, "ysqm", "0").toString()) && ysqm_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "随访医生签名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "jmqm", "0").toString()) && jmqm_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "家属或本人签名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "xcpz", "0").toString()) && pz_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "现场拍照不能为空");
                }else {
                    if (obj == null)
                        obj = new XseJtfs();
                    obj.setCSRQ(csrq.getText().toString());
                    obj.setSFZH(sfzh.getText().toString());
                    obj.setJTZZ(jtzz.getText().toString());
                    obj.setFQNAME(fqxm.getText().toString());
                    obj.setFQZY(fqzy.getText().toString());
                    obj.setFQLXDH(fqlxdh.getText().toString());
                    obj.setFQSFZH(fqsfzj.getText().toString());
                    obj.setMQNAME(mq.getText().toString());
                    obj.setMQZY(mqzzy.getText().toString());
                    obj.setMQLXDH(mqlxdh.getText().toString());
                    obj.setMQSFZH(mqsfzh.getText().toString());
                    obj.setCSYZ(csyz.getText().toString());
                    obj.setMQRSQQT(mqrxqt.getText().toString());
                    obj.setZCJGMC(zcjgmc.getText().toString());
                    ArrayList<Integer> cszklist = cszk.getAllItemSelectedIndex();
                    String cszks = "";
                    for (int i = 0; i < cszklist.size(); i++) {
                        if (i == 0)
                            cszks = cszklist.get(i) + "";
                        else
                            cszks = cszks + "," + cszklist.get(i);
                    }
                    obj.setCSQK(cszks);
                    obj.setCSQTQK(cszkqt.getText().toString());
                    ArrayList<Integer> jbsclist = xsejbsc.getAllItemSelectedIndex();
                    String jbscs = "";
                    for (int i = 0; i < jbsclist.size(); i++) {
                        if (i == 0)
                            jbscs = jbsclist.get(i) + "";
                        else
                            jbscs = jbscs + "," + jbsclist.get(i);
                    }
                    obj.setXSEJBSC(jbscs);
                    obj.setXSECSTZ(xsecstz.getText().toString());
                    obj.setMQTZ(mqtz.getText().toString());
                    obj.setCSSC(cssc.getText().toString());
                    obj.setCNL(cnl.getText().toString());
                    obj.setDABIANQT(dbqt.getText().toString());
                    obj.setDBCS(dbcs.getText().toString());
                    obj.setTIWEN(tw.getText().toString());
                    obj.setMAILV(xl.getText().toString());
                    obj.setHXPL(hxpl.getText().toString());
                    obj.setMIANSEQT(msqt.getText().toString());
                    ArrayList<Integer> hylist = xsejbsc.getAllItemSelectedIndex();
                    String hys = "";
                    for (int i = 0; i < hylist.size(); i++) {
                        if (i == 0)
                            hys = hylist.get(i) + "";
                        else
                            hys = hys + "," + hylist.get(i);
                    }
                    obj.setHDBW(hys);
                    obj.setQL1(qx1.getText().toString());
                    obj.setQL2(qx2.getText().toString());
                    obj.setQLQKQT(qxqt.getText().toString());
                    ArrayList<Integer> zdslist = xsejbsc.getAllItemSelectedIndex();
                    String zds = "";
                    for (int i = 0; i < zdslist.size(); i++) {
                        if (i == 0)
                            zds = zdslist.get(i) + "";
                        else
                            zds = zds + "," + zdslist.get(i);
                    }
                    obj.setZHIDAO(zds);
                    obj.setZHIDAOQT(zdqt.getText().toString());
                    obj.setZZYY(zzyy.getText().toString());
                    obj.setZZJGJKS(jgjkb.getText().toString());
                    obj.setZZLXR(lxr.getText().toString());
                    obj.setZZLXFS(lxdh.getText().toString());
                    obj.setSFRQ(DateConvert.dateToString(DateConvert.toDate(bcsfrq.getText().toString(), DateConvert.YMD), DateConvert.YMD)+"");
                    obj.setXCSFRQ(DateConvert.dateToString(DateConvert.toDate(xcsfrq.getText().toString(), DateConvert.YMD), DateConvert.YMD)+"");
                    if (NetWorkUtils.isNetworkConnected(con)) {///网络连接
                        RequestParams ps = new RequestParams();
                        ps.add("entity.XINGMING", obj.getXINGMING());
                        ps.add("entity.XINGBIE", obj.getXINGBIE());
                        ps.add("entity.CSRQ", obj.getCSRQ());
                        ps.add("entity.SFZH", obj.getSFZH());
                        ps.add("entity.JTZZ", obj.getJTZZ());
                        ps.add("entity.FQNAME", obj.getFQNAME());
                        ps.add("entity.FQZY", obj.getFQZY());
                        ps.add("entity.FQLXDH", obj.getFQLXDH());
                        ps.add("entity.FQSFZH", obj.getFQSFZH());
                        ps.add("entity.MQNAME", obj.getMQNAME());
                        ps.add("entity.MQZY", obj.getMQZY());
                        ps.add("entity.MQLXDH", obj.getMQLXDH());
                        ps.add("entity.MQSFZH", obj.getMQSFZH());
                        ps.add("entity.CSYZ", obj.getCSYZ());
                        ps.add("entity.CSQK", obj.getCSQK());
                        ps.add("entity.CSQTQK", obj.getCSQTQK());
                        ps.add("entity.XSEZX", obj.getXSEZX());
                        ps.add("entity.JIXING", obj.getJIXING());
                        ps.add("entity.XSETLSC", obj.getXSETLSC());
                        ps.add("entity.XSEJBSC", obj.getXSEJBSC());
                        ps.add("entity.XSECSTZ", obj.getXSECSTZ());
                        ps.add("entity.MQTZ", obj.getMQTZ());
                        ps.add("entity.CSSC", obj.getCSSC());
                        ps.add("entity.WYFS", obj.getWYFS());
                        ps.add("entity.CNL", obj.getCNL());
                        ps.add("entity.CNCS", obj.getCNCS());
                        ps.add("entity.OUTU", obj.getOUTU());
                        ps.add("entity.DABIAN", obj.getDABIAN());
                        ps.add("entity.DBCS", obj.getDBCS());
                        ps.add("entity.TIWEN", obj.getTIWEN());
                        ps.add("entity.MAILV", obj.getMAILV());
                        ps.add("entity.HXPL", obj.getHXPL());
                        ps.add("entity.MIANSE", obj.getMIANSE());
                        ps.add("entity.MIANSEQT", obj.getMIANSEQT());
                        ps.add("entity.HDBW", obj.getHDBW());
                        ps.add("entity.QLQK", obj.getQLQK());
                        ps.add("entity.QL1", obj.getQL1());
                        ps.add("entity.QL2", obj.getQL2());
                        ps.add("entity.QLQKQT", obj.getQLQKQT());
                        ps.add("entity.YWG", obj.getYWG());
                        ps.add("entity.SZHDD", obj.getSZHDD());
                        ps.add("entity.EWG", obj.getEWG());
                        ps.add("entity.JBBK", obj.getJBBK());
                        ps.add("entity.PIFU", obj.getPIFU());
                        ps.add("entity.KOUQIANG", obj.getKOUQIANG());
                        ps.add("entity.GANGMEN", obj.getGANGMEN());
                        ps.add("entity.XFTZ", obj.getXFTZ());
                        ps.add("entity.XB", obj.getXB());
                        ps.add("entity.FBCZ", obj.getFBCZ());
                        ps.add("entity.JIZHU", obj.getJIZHU());
                        ps.add("entity.WSZQ", obj.getWSZQ());
                        ps.add("entity.QIDAI", obj.getQIDAI());
                        ps.add("entity.QIDAIQT", obj.getQIDAIQT());
                        ps.add("entity.ZHIDAO", obj.getZHIDAO());
                        ps.add("entity.ZHIDAOQT", obj.getZHIDAOQT());
                        ps.add("entity.SFZZ", obj.getSFZZ());
                        ps.add("entity.ZZYY", obj.getZZYY());
                        ps.add("entity.ZZJGJKS", obj.getZZJGJKS());
                        ps.add("entity.ZZLXR", obj.getZZLXR());
                        ps.add("entity.ZZLXFS", obj.getZZLXFS());
                        ps.add("entity.ZZJG", obj.getZZJG());
                        ps.add("entity.SFRQ", obj.getSFRQ());
                        ps.add("entity.XCSFRQ", obj.getXCSFRQ());
                        ps.add("entity.CARDNUM", obj.getCARDNUM());
                        ps.add("token", SharedPreferencesUtils.getParam(con, "token", "").toString());
                        ps.add("type", "2");
                        if (isadd) {
                            ps.add("entity.JKDAH", JKDAH);
                            url = HttpUrl.SaveXseSfjl;
                        } else {
                            ps.add("entity.SFJLH", obj.getSFJLH());
                            ps.add("entity.JKDAH", obj.getJKDAH());
                            url = HttpUrl.EditXseSfjl;
                        }

                        ps.add("pz_record_id", pz_record_id.getText().toString());
                        ps.add("jmqm_record_id", jmqm_record_id.getText().toString());
                        ps.add("ysqm_record_id", jmqm_record_id.getText().toString());
                        ps.add("entity.UPDATETIME", obj.getUPDATETIME());
                        //yyye_xser.super.ImageUploadOperate(sfysqmpic, brqmpic, ps);
                        UserClient.get(url, ps, new AsyncHttpResponseHandler() {
                            @Override
                            public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                                String content = new String(response);
                                RetMsg ret = JSON.parseObject(content, RetMsg.class);
                                if (ret.getCode().equals("200")) {
                                    MyToastUtil.ShowToast(con, "成功");
                                }else{
                                    MyToastUtil.ShowToast(con, ret.getInfo());
                                }
                                finish();
                            }

                            @Override
                            public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {

                                MyToastUtil.ShowToast(con, "失败");
                            }
                        });
                    }
                }
            }
        });
        //转诊
        dbqt = (EditText) findViewById(R.id.dbqt);
        if (obj != null && !StringUtils.isEmpty(obj.getDABIANQT())) {
            dbqt.setText(obj.getDABIANQT());
        }
        zzyy = (EditText) findViewById(R.id.zz_yy);
        if (obj != null && !StringUtils.isEmpty(obj.getZZYY())) {
            zzyy.setText(obj.getZZYY());
        }
        jgjkb = (EditText) findViewById(R.id.zzjg);
        if (obj != null && !StringUtils.isEmpty(obj.getZZJG())) {
            jgjkb.setText(obj.getZZJG());
        }
        lxr = (EditText) findViewById(R.id.zz_lxr);
        if (obj != null && !StringUtils.isEmpty(obj.getZZLXR())) {
            lxr.setText(obj.getZZLXR());
        }

        lxdh = (EditText) findViewById(R.id.zz_lxfs);
        if (obj != null && !StringUtils.isEmpty(obj.getZZLXFS())) {
            lxdh.setText(obj.getZZLXFS());
        }
        zzjg = (RadioGroup) findViewById(R.id.jg);
        if (obj != null && !StringUtils.isEmpty(obj.getZZJG())) {
            switch (Integer.parseInt(obj.getZZJG())) {
                case 1:
                    zzjg.check(R.id.dw);
                    break;
                case 2:
                    zzjg.check(R.id.wdw);
                    break;
            }
        }
        zzjg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.dw)
                    obj.setZZJG("1");
                else
                    obj.setZZJG("2");
            }
        });
        zz = (RadioGroup) findViewById(R.id.zz);
        if (obj != null && !StringUtils.isEmpty(obj.getSFZZ())) {
            switch (Integer.parseInt(obj.getSFZZ())) {
                case 1:
                    zz.check(R.id.zz_wu);
                    break;
                case 2:
                    zz.check(R.id.zz_you);
                    break;
            }
        }
        zz.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.zz_wu)
                    obj.setSFZZ("1");
                else
                    obj.setSFZZ("2");

            }
        });
        xcsfrq = (TextView) findViewById(R.id.xcsfrq);
        if (obj != null && !StringUtils.isEmpty(obj.getXCSFRQ())) {
            xcsfrq.setText(obj.getXCSFRQ());
        }
        xcsfrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        xcsfrq.setText(time.split(" ")[0]);

                    }
                }, DateConvert.getCustomDatePickerStartRq(), DateConvert.getCustomDatePickerEndRq()); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(DateConvert.getCustomDatePickerNowRq());
            }
        });
        bcsfrq = (TextView) findViewById(R.id.bcsfrq);
        if (obj != null && !StringUtils.isEmpty(obj.getSFRQ())) {
//            bcsfrq.setText(obj.getSFRQ());
            bcsfrq.setText(DateConvert.dateToString(DateConvert.toDate(obj.getSFRQ(), DateConvert.YMD), DateConvert.YMD)+"");
        }
        bcsfrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        bcsfrq.setText(time.split(" ")[0]);

                    }
                }, "2010-01-01 00:00", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        /////////////////////////////////////////////////////////////////////////////指导

        bjzd = (MultiLineChooseLayout) findViewById(R.id.zhidao);
        bjzddata.add("喂养指导");
        bjzddata.add("发育指导");
        bjzddata.add("防病指导");
        bjzddata.add("预防伤害指导");
        bjzddata.add("口腔保健指导");
        bjzddata.add("其他");
        bjzd.setList(bjzddata);
        if (obj != null && !StringUtils.isEmpty(obj.getZHIDAO())) {
            if (obj.getZHIDAO().contains("1"))
                bjzd.setIndexItemSelected(0);
            if (obj.getZHIDAO().contains("2"))
                bjzd.setIndexItemSelected(1);
            if (obj.getZHIDAO().contains("3"))
                bjzd.setIndexItemSelected(2);
            if (obj.getZHIDAO().contains("4"))
                bjzd.setIndexItemSelected(3);
            if (obj.getZHIDAO().contains("5"))
                bjzd.setIndexItemSelected(4);
            if (obj.getZHIDAO().contains("6"))
                bjzd.setIndexItemSelected(5);
        }

        zdqt = (EditText) findViewById(R.id.zd_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getZHIDAOQT())) {
            zdqt.setText(obj.getZHIDAOQT());
        }
//////////////////////////////////////////////////////////////////////////////////////////内容1
        csrq = (TextView) findViewById(R.id.csrq);
        if (obj != null && !StringUtils.isEmpty(obj.getCSRQ())) {
            csrq.setText(obj.getCSRQ());
        }
        csrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        csrq.setText(time.split(" ")[0]);

                    }
                }, "2010-01-01 00:00", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        sfzh = (EditText) findViewById(R.id.sfzh);
        if (obj != null && !StringUtils.isEmpty(obj.getSFZH())) {
            sfzh.setText(obj.getSFZH());
        }
        jtzz = (EditText) findViewById(R.id.jtzz);
        if (obj != null && !StringUtils.isEmpty(obj.getJTZZ())) {
            jtzz.setText(obj.getJTZZ());
        }
        fqxm = (EditText) findViewById(R.id.fqxm);
        if (obj != null && !StringUtils.isEmpty(obj.getFQNAME())) {
            fqxm.setText(obj.getFQNAME());
        }
        fqzy = (EditText) findViewById(R.id.fqzy);
        if (obj != null && !StringUtils.isEmpty(obj.getFQZY())) {
            fqzy.setText(obj.getFQZY());
        }
        fqlxdh = (EditText) findViewById(R.id.fq_lxdh);
        if (obj != null && !StringUtils.isEmpty(obj.getFQLXDH())) {
            fqlxdh.setText(obj.getFQLXDH());
        }
        fqsfzj = (EditText) findViewById(R.id.fqsfzh);
        if (obj != null && !StringUtils.isEmpty(obj.getFQSFZH())) {
            fqlxdh.setText(obj.getFQSFZH());
        }
        mq = (EditText) findViewById(R.id.mq);
        if (obj != null && !StringUtils.isEmpty(obj.getMQNAME())) {
            mq.setText(obj.getMQNAME());
        }
        mqzzy = (EditText) findViewById(R.id.mqzy);
        if (obj != null && !StringUtils.isEmpty(obj.getMQZY())) {
            mqzzy.setText(obj.getMQZY());
        }
        mqlxdh = (EditText) findViewById(R.id.mqlxdh);
        if (obj != null && !StringUtils.isEmpty(obj.getMQLXDH())) {
            mqlxdh.setText(obj.getMQLXDH());
        }
        mqsfzh = (EditText) findViewById(R.id.mqsfzh);
        if (obj != null && !StringUtils.isEmpty(obj.getMQSFZH())) {
            mqsfzh.setText(obj.getMQSFZH());
        }
        csyz = (EditText) findViewById(R.id.csyz);
        if (obj != null && !StringUtils.isEmpty(obj.getCSYZ())) {
            csyz.setText(obj.getCSYZ());
        }

        mqrx = (RadioGroup) findViewById(R.id.mqrx);
        if (obj != null && !StringUtils.isEmpty(obj.getMQRSQHBQK())) {
            switch (Integer.parseInt(obj.getMQRSQHBQK())) {
                case 1:
                    mqrx.check(R.id.mqrx1);
                    break;
                case 2:
                    mqrx.check(R.id.mqrx2);
                    break;
                case 3:
                    mqrx.check(R.id.mqrx3);
                    break;
                case 4:
                    mqrx.check(R.id.mqrx4);
                    break;
            }
        }
        mqrx.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.mqrx1) {
                    obj.setMQRSQHBQK("1");
                } else if (i == R.id.mqrx2) {
                    obj.setMQRSQHBQK("2");
                } else if (i == R.id.mqrx3) {
                    obj.setMQRSQHBQK("3");
                } else {
                    obj.setMQRSQHBQK("4");
                }
            }
        });
        mqrxqt = (EditText)

                findViewById(R.id.mqrxqt);
        if (obj != null && !StringUtils.isEmpty(obj.getMQRSQQT()))

        {
            mqrxqt.setText(obj.getMQRSQQT());
        }

        zcjgmc = (EditText)

                findViewById(R.id.zcjgmc);
        if (obj != null && !StringUtils.isEmpty(obj.getZCJGMC()))

        {
            zcjgmc.setText(obj.getZCJGMC());
        }

        cszk = (MultiLineChooseLayout)

                findViewById(R.id.cszk);
        cszkdata.add("顺产");
        cszkdata.add("胎头吸引");
        cszkdata.add("产钳");
        cszkdata.add("剖宫 ");
        cszkdata.add("双多胎 ");
        cszkdata.add("臀位");
        cszkdata.add("其他");
        cszk.setList(cszkdata);
        if (obj != null && !StringUtils.isEmpty(obj.getCSQK())) {
            if (obj.getCSQK().contains(",")) {
                String[] ss = obj.getCSQK().split(",");
                for (int i = 0; i < ss.length; i++) {
                    if (!StringUtils.isEmpty(ss[i])) {
                        cszk.setIndexItemSelected(Integer.parseInt(ss[i]));
                    }
                }
            } else {
                cszk.setIndexItemSelected(Integer.parseInt(obj.getCSQK()));
            }
        }
        cszkqt = (EditText)

                findViewById(R.id.cszk_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getCSQTQK()))

        {
            cszkqt.setText(obj.getCSQTQK());
        }
        /////////////////////////////////////////////////////////////////////新生儿窒息/机型/听力筛查
        xsezx = (RadioGroup)

                findViewById(R.id.xsezx);
        if (obj != null && !StringUtils.isEmpty(obj.getXSEZX()))

        {
            switch (Integer.parseInt(obj.getXSEZX())) {
                case 1:
                    xsezx.check(R.id.xsezx_wu);
                    break;
                case 2:
                    xsezx.check(R.id.xsezx_you);
                    break;

            }
        }
        xsezx.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.xsezx_wu) {
                    obj.setXSEZX("1");
                } else {
                    obj.setXSEZX("2");

                }
            }
        });
        jx = (RadioGroup)

                findViewById(R.id.jx);
        if (obj != null && !StringUtils.isEmpty(obj.getJIXING()))

        {
            switch (Integer.parseInt(obj.getJIXING())) {
                case 1:

                    jx.check(R.id.jx_wu);
                    break;
                case 2:
                    jx.check(R.id.jx_you);
                    break;

            }
        }
        jx.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.jx_wu) {
                    obj.setJIXING("1");
                } else {
                    obj.setJIXING("2");

                }
            }
        });
        xsetlsc = (RadioGroup)

                findViewById(R.id.xsetlsc);
        if (obj != null && !StringUtils.isEmpty(obj.getXSETLSC()))

        {
            switch (Integer.parseInt(obj.getXSETLSC())) {
                case 1:
                    xsetlsc.check(R.id.xsetlsc1);
                    break;
                case 2:
                    xsetlsc.check(R.id.xsetlsc2);
                    break;
                case 3:
                    xsetlsc.check(R.id.xsetlsc3);
                    break;
                case 4:
                    xsetlsc.check(R.id.xsetlsc4);
                    break;

            }
        }
        xsetlsc.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.xsetlsc1) {
                    obj.setXSETLSC("1");
                } else if (i == R.id.xsetlsc2) {
                    obj.setXSETLSC("2");

                } else if (i == R.id.xsetlsc3) {
                    obj.setXSETLSC("3");
                } else {
                    obj.setXSETLSC("4");
                }

            }
        });

        xsejbsc = (MultiLineChooseLayout)

                findViewById(R.id.xsejbsc);
        xsejbscdata.add("未进行");
        xsejbscdata.add("检查均阴性");
        xsejbscdata.add("甲低");
        xsejbscdata.add("苯丙酮尿症");
        xsejbscdata.add("先天性肾上腺皮质增生症");
        xsejbscdata.add("葡糖糖-6-磷酸脱氢酶缺乏症");
        xsejbscdata.add("其他遗传代谢 ");
        xsejbsc.setList(xsejbscdata);
        if (obj != null && !StringUtils.isEmpty(obj.getXSEJBSC())) {
            if (obj.getXSEJBSC().contains(",")) {
                String[] ss = obj.getXSEJBSC().split(",");
                for (int i = 0; i < ss.length; i++) {
                    if (!StringUtils.isEmpty(ss[i])) {
                        xsejbsc.setIndexItemSelected(Integer.parseInt(ss[i]));
                    }
                }
            } else {
                xsejbsc.setIndexItemSelected(Integer.parseInt(obj.getXSEJBSC()));
            }
        }

        //////////////////////////////////////////////////////////////////////////////////////////////

        xsecstz = (EditText)

                findViewById(R.id.xsecstz);
        if (obj != null && !StringUtils.isEmpty(obj.getXSECSTZ()))

        {
            xsecstz.setText(obj.getXSECSTZ());
        }

        mqtz = (EditText)

                findViewById(R.id.mqtz);
        if (obj != null && !StringUtils.isEmpty(obj.getMQTZ()))

        {
            mqtz.setText(obj.getMQTZ());
        }

        cssc = (EditText)

                findViewById(R.id.cssc);
        if (obj != null && !StringUtils.isEmpty(obj.getCSSC()))

        {
            cssc.setText(obj.getCSSC());
        }

        wyfs = (RadioGroup)

                findViewById(R.id.wyfs);
        if (obj != null && !StringUtils.isEmpty(obj.getWYFS()))

        {
            switch (Integer.parseInt(obj.getWYFS())) {
                case 1:
                    wyfs.check(R.id.wyfs_cmr);
                    break;
                case 2:
                    wyfs.check(R.id.wyfs_hh);
                    break;
                case 3:
                    wyfs.check(R.id.wyfs_rg);
                    break;
            }
        }
        wyfs.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.wyfs_cmr) {
                    obj.setWYFS("1");
                } else if (i == R.id.wyfs_hh) {
                    obj.setWYFS("2");
                } else {
                    obj.setWYFS("3");
                }
            }
        });
        cnl = (EditText)

                findViewById(R.id.cnl);
        if (obj != null && !StringUtils.isEmpty(obj.getCNL()))

        {
            cnl.setText(obj.getCNL());
        }

        cncs = (EditText)

                findViewById(R.id.cncs);
        if (obj != null && !StringUtils.isEmpty(obj.getCNCS()))

        {
            cncs.setText(obj.getCNCS());
        }


        outu = (RadioGroup)

                findViewById(R.id.ot);
        if (obj != null && !StringUtils.isEmpty(obj.getOUTU()))

        {
            switch (Integer.parseInt(obj.getWYFS())) {
                case 1:
                    outu.check(R.id.ot_wu);
                    break;
                case 2:
                    outu.check(R.id.ot_you);
                    break;

            }
        }
        outu.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.wyfs_cmr) {
                    obj.setOUTU("1");

                } else {
                    obj.setOUTU("2");
                }
            }
        });

        dabian = (RadioGroup)

                findViewById(R.id.db);
        if (obj != null && !StringUtils.isEmpty(obj.getDABIAN()))

        {
            switch (Integer.parseInt(obj.getDABIAN())) {
                case 1:
                    dabian.check(R.id.db_hz);
                    break;
                case 2:
                    dabian.check(R.id.db_x);
                    break;
                case 3:
                    dabian.check(R.id.db_qt);
                    break;

            }
        }
        dabian.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.db_hz) {
                    obj.setDABIAN("1");
                } else if (i == R.id.db_x) {
                    obj.setDABIAN("2");
                } else {
                    obj.setDABIAN("3");
                }
            }
        });

        dbcs = (EditText)

                findViewById(R.id.dbcs);
        if (obj != null && !StringUtils.isEmpty(obj.getDBCS()))

        {
            dbcs.setText(obj.getDBCS());
        }

        tw = (EditText)

                findViewById(R.id.tw);
        if (obj != null && !StringUtils.isEmpty(obj.getTIWEN()))

        {
            tw.setText(obj.getTIWEN());
        }

        xl = (EditText)

                findViewById(R.id.xl);
        if (obj != null && !StringUtils.isEmpty(obj.getMAILV()))

        {
            xl.setText(obj.getMAILV());
        }

        hxpl = (EditText)

                findViewById(R.id.hxpl);
        if (obj != null && !StringUtils.isEmpty(obj.getHXPL()))

        {
            hxpl.setText(obj.getHXPL());
        }

        mshr = (RadioGroup)

                findViewById(R.id.mshr);
        if (obj != null && !StringUtils.isEmpty(obj.getMIANSE()))

        {
            switch (Integer.parseInt(obj.getMIANSE())) {
                case 1:
                    mshr.check(R.id.mshr_hr);
                    break;
                case 2:
                    mshr.check(R.id.mshr_huang);
                    break;
                case 3:
                    mshr.check(R.id.mshr_qts);
                    break;

            }
        }
        mshr.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.mshr_hr) {
                    obj.setMIANSE("1");
                } else if (i == R.id.mshr_huang) {
                    obj.setMIANSE("2");
                } else {
                    obj.setMIANSE("3");
                }
            }
        });
        msqt = (EditText)

                findViewById(R.id.mshr_qtdes);
        if (obj != null && !StringUtils.isEmpty(obj.getMIANSEQT()))

        {
            msqt.setText(obj.getMIANSEQT());
        }

        hybw = (MultiLineChooseLayout)

                findViewById(R.id.hdbw);
        hybwdata.add("无");
        hybwdata.add("面部");
        hybwdata.add("躯干");
        hybwdata.add("四肢");
        hybwdata.add("手足");
        hybw.setList(hybwdata);
        if (obj != null && !StringUtils.isEmpty(obj.getHDBW()))

        {
            if (obj.getHDBW().contains(",")) {
                String[] ss = obj.getHDBW().split(",");
                for (int i = 0; i < ss.length; i++) {
                    if (!StringUtils.isEmpty(ss[i])) {
                        hybw.setIndexItemSelected(Integer.parseInt(ss[i]));
                    }
                }
            } else {
                hybw.setIndexItemSelected(Integer.parseInt(obj.getHDBW()));
            }
        }

        qx1 = (EditText)

                findViewById(R.id.qx1);
        if (obj != null && !StringUtils.isEmpty(obj.getQL1()))

        {
            qx1.setText(obj.getQL1());
        }

        qx2 = (EditText)

                findViewById(R.id.qx2);
        if (obj != null && !StringUtils.isEmpty(obj.getQL2()))

        {
            qx2.setText(obj.getQL2());
        }

        qx = (RadioGroup)

                findViewById(R.id.qx);
        if (obj != null && !StringUtils.isEmpty(obj.getQLQK()))

        {
            switch (Integer.parseInt(obj.getQLQK())) {
                case 1:
                    qx.check(R.id.qx_zc);
                    break;
                case 2:
                    qx.check(R.id.qx_pl);
                    break;
                case 3:
                    qx.check(R.id.qx_ax);
                    break;

            }
        }
        qx.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.qx_zc) {
                    obj.setQLQK("1");
                } else if (i == R.id.qx_pl) {
                    obj.setQLQK("2");
                } else {
                    obj.setQLQK("3");
                }
            }
        });
        qxqt = (EditText)

                findViewById(R.id.qx_qtdes);
        if (obj != null && !StringUtils.isEmpty(obj.getQLQKQT()))

        {
            qxqt.setText(obj.getQLQKQT());
        }
        yj = (RadioGroup)
                findViewById(R.id.yj);
        if (obj != null && !StringUtils.isEmpty(obj.getYWG()))

        {
            switch (Integer.parseInt(obj.getYWG())) {
                case 1:
                    yj.check(R.id.yj_wu);
                    break;
                case 2:
                    yj.check(R.id.yj_you);
                    break;


            }
        }
        yj.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.yj_wu) {
                    obj.setYWG("1");
                } else {
                    obj.setYWG("2");
                }
            }
        });

        szhdd = (RadioGroup)
                findViewById(R.id.szhdd);
        if (obj != null && !StringUtils.isEmpty(obj.getSZHDD()))

        {
            switch (Integer.parseInt(obj.getSZHDD())) {
                case 1:
                    szhdd.check(R.id.szhdd_wu);
                    break;
                case 2:
                    szhdd.check(R.id.szhdd_you);
                    break;


            }
        }
        szhdd.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.szhdd_wu) {
                    obj.setSZHDD("1");
                } else {
                    obj.setSZHDD("2");
                }
            }
        });
        wg = (RadioGroup)

                findViewById(R.id.ewg);
        if (obj != null && !StringUtils.isEmpty(obj.getEWG()))

        {
            switch (Integer.parseInt(obj.getEWG())) {
                case 1:
                    wg.check(R.id.ewg_wu);
                    break;
                case 2:
                    wg.check(R.id.ewg_you);
                    break;


            }
        }
        wg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.ewg_wu) {
                    obj.setEWG("1");
                } else {
                    obj.setEWG("2");
                }
            }
        });

        jbbk = (RadioGroup)

                findViewById(R.id.jbbk);
        if (obj != null && !StringUtils.isEmpty(obj.getEWG()))

        {
            switch (Integer.parseInt(obj.getEWG())) {
                case 1:
                    jbbk.check(R.id.jbbk_wu);
                    break;
                case 2:
                    jbbk.check(R.id.jbbk_you);
                    break;


            }
        }
        jbbk.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.jbbk_wu) {
                    obj.setJBBK("1");
                } else {
                    obj.setJBBK("2");
                }
            }
        });

        bi = (RadioGroup)

                findViewById(R.id.bi);
        if (obj != null && !StringUtils.isEmpty(obj.getEWG()))

        {
            switch (Integer.parseInt(obj.getEWG())) {
                case 1:
                    bi.check(R.id.bi_wu);
                    break;
                case 2:
                    bi.check(R.id.bi_you);
                    break;


            }
        }
        bi.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.bi_wu) {
                    obj.setBI("1");
                } else {
                    obj.setBI("2");
                }
            }
        });
        pf = (RadioGroup)

                findViewById(R.id.pf);
        if (obj != null && !StringUtils.isEmpty(obj.getPIFU()))

        {
            switch (Integer.parseInt(obj.getPIFU())) {
                case 1:
                    pf.check(R.id.pf_wjyc);
                    break;
                case 2:
                    pf.check(R.id.pf_sz);
                    break;
                case 3:
                    pf.check(R.id.pf_ml);
                    break;
                case 4:
                    pf.check(R.id.pf_qt);
                    break;
            }
        }
        pf.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.pf_wjyc) {
                    obj.setPIFU("1");
                } else if (i == R.id.pf_sz) {
                    obj.setPIFU("2");
                } else if (i == R.id.pf_ml) {
                    obj.setPIFU("3");
                } else {
                    obj.setPIFU("4");
                }
            }
        });

        kq = (RadioGroup)

                findViewById(R.id.kq);
        if (obj != null && !StringUtils.isEmpty(obj.getGANGMEN()))

        {
            switch (Integer.parseInt(obj.getGANGMEN())) {
                case 1:
                    kq.check(R.id.kq_wu);
                    break;
                case 2:
                    kq.check(R.id.kq_you);
                    break;


            }
        }
        kq.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.kq_wu) {
                    obj.setKOUQIANG("1");
                } else {
                    obj.setKOUQIANG("2");
                }
            }
        });
        gm = (RadioGroup)

                findViewById(R.id.gm);
        if (obj != null && !StringUtils.isEmpty(obj.getGANGMEN()))

        {
            switch (Integer.parseInt(obj.getGANGMEN())) {
                case 1:
                    gm.check(R.id.gm_wu);
                    break;
                case 2:
                    gm.check(R.id.gm_you);
                    break;


            }
        }
        gm.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.gm_wu) {
                    obj.setGANGMEN("1");
                } else {
                    obj.setGANGMEN("2");
                }
            }
        });

        xftz = (RadioGroup)

                findViewById(R.id.xftz);
        if (obj != null && !StringUtils.isEmpty(obj.getXFTZ()))

        {
            switch (Integer.parseInt(obj.getXFTZ())) {
                case 1:
                    xftz.check(R.id.xftz_wu);
                    break;
                case 2:
                    xftz.check(R.id.xftz_you);
                    break;


            }
        }
        xftz.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.xftz_wu) {
                    obj.setXFTZ("1");
                } else {
                    obj.setXFTZ("2");
                }
            }
        });
        xingbie = (RadioGroup)

                findViewById(R.id.xb);
        if (obj != null && !StringUtils.isEmpty(obj.getXINGBIE()))

        {
            switch (Integer.parseInt(obj.getXINGBIE())) {
                case 1:
                    xingbie.check(R.id.nan);
                    break;
                case 2:
                    xingbie.check(R.id.nv);
                    break;


            }
        }
        xingbie.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.nan) {
                    obj.setXINGBIE("1");
                } else {
                    obj.setXINGBIE("2");

                }
            }
        });
        xb = (RadioGroup)

                findViewById(R.id.xiong);
        if (obj != null && !StringUtils.isEmpty(obj.getXB()))

        {
            switch (Integer.parseInt(obj.getXB())) {
                case 1:
                    xb.check(R.id.xb_wu);
                    break;
                case 2:
                    xb.check(R.id.xb_you);
                    break;


            }
        }
        xb.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.xb_wu) {
                    obj.setXB("1");
                } else {
                    obj.setXB("2");

                }
            }
        });

        fbcz = (RadioGroup)

                findViewById(R.id.fbcz);
        if (obj != null && !StringUtils.isEmpty(obj.getFBCZ()))

        {
            switch (Integer.parseInt(obj.getFBCZ())) {
                case 1:
                    fbcz.check(R.id.fbcz_wu);
                    break;
                case 2:
                    fbcz.check(R.id.fbcz_you);
                    break;
            }
        }
        fbcz.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.fbcz_wu) {
                    obj.setFBCZ("1");
                } else {
                    obj.setFBCZ("2");
                }
            }
        });

        jz = (RadioGroup)

                findViewById(R.id.jz);
        if (obj != null && !StringUtils.isEmpty(obj.getJIZHU()))

        {
            switch (Integer.parseInt(obj.getJIZHU())) {
                case 1:
                    jz.check(R.id.jz_wu);
                    break;
                case 2:
                    jz.check(R.id.jz_you);
                    break;


            }
        }
        jz.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.jz_wu) {
                    obj.setJIZHU("1");
                } else {
                    obj.setJIZHU("2");
                }
            }
        });
        wszq = (RadioGroup)

                findViewById(R.id.wszq);
        if (obj != null && !StringUtils.isEmpty(obj.getJIZHU()))

        {
            switch (Integer.parseInt(obj.getJIZHU())) {
                case 1:
                    wszq.check(R.id.wszq_wu);
                    break;
                case 2:
                    wszq.check(R.id.wszq_you);
                    break;


            }
        }
        wszq.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.wszq_wu) {
                    obj.setWSZQ("1");
                } else {
                    obj.setWSZQ("2");
                }
            }
        });
        qd = (RadioGroup)

                findViewById(R.id.qd);
        if (obj != null && !StringUtils.isEmpty(obj.getQIDAI()))

        {
            switch (Integer.parseInt(obj.getQIDAI())) {
                case 1:
                    qd.check(R.id.qd_wt);
                    break;
                case 2:
                    qd.check(R.id.qd_tl);
                    break;
                case 3:
                    qd.check(R.id.qd_qbysc);
                    break;
                case 4:
                    qd.check(R.id.qd_qt);
                    break;

            }
        }
        qd.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()

        {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.qd_wt) {
                    obj.setQIDAI("1");
                } else if (i == R.id.qd_tl) {
                    obj.setQIDAI("2");
                } else if (i == R.id.qd_qbysc) {
                    obj.setQIDAI("3");
                } else {
                    obj.setQIDAI("4");
                }
            }
        });
        qdqt = (EditText)
                findViewById(R.id.qd_qtdes);
        if (obj != null && !StringUtils.isEmpty(obj.getQIDAIQT()))

        {
            qdqt.setText(obj.getQIDAIQT());
        }
    }

    public void getObject() {
        RequestParams ps = new RequestParams();
        ps.add("token", SharedPreferencesUtils.getParam(con, "token", "").toString());
        ps.add("type", "2");
        ps.add("CARDNUM", j.getCARDNUM());
        UserClient.get(HttpUrl.GetXseGetGrjbxx, ps, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                String content = new String(response);
                Log.i("ycf2", content);
                RetMsg ret = JSON.parseObject(content, RetMsg.class);
                if (ret.getCode().equals("200")) {
                    if (StringUtils.isEmpty(ret.getOtherParams())) {//other是空的
                        JSONObject j = JSON.parseObject(ret.getRd());
                        obj = new XseJtfs();
                        obj.setJKDAH(j.getString("JKDAH"));
                        obj.setXINGMING(j.getString("XINGMING"));
                        obj.setCARDNUM(j.getString("CARDNUM"));
                        JKDAH = j.getString("JKDAH");
                        xm.setText(j.getString("XINGMING"));
                        obj.setXINGBIE(j.getString("XINGBIE"));
                        if (obj != null && !StringUtils.isEmpty(obj.getXINGBIE())) {
                            switch (Integer.parseInt(obj.getXINGBIE())) {
                                case 1:
                                    xb.check(R.id.nan);
                                    break;
                                case 2:
                                    xb.check(R.id.nv);
                                    break;
                            }
                        }
                        sfzh.setText(j.getString("SFZH"));
                        jtzz.setText(j.getString("JTZZ"));
                        isadd = true;
                    } else {
                        isadd = false;
                        obj = JSON.parseObject(ret.getRd(), XseJtfs.class);
                    }
                } else {
                    SweetAlertDialogUtil.ErrorDialogNoFinish(con, "错误提示", ret.getInfo(), "确定");
                }
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {

                obj = new XseJtfs();
                init();
            }
        });
    }

    class CustomerListener implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            if(obj != null && StringUtils.isEmpty(obj.getJKDAH())) {
                SweetAlertDialogUtil.WarningDialog(con, "提示", "选择居民用户后才能现场拍照");
            }else {
                Intent intent = new Intent(con, CameraChoose.class)
                        .putExtra("type", "edit")
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "xsejtfs")
                        .putExtra("class", "yyye_xser.class");
                startActivityForResult(intent, 119);
            }
        }
    }
}
